package cn.yuan.xiaoyu.jokemodule.presenter;

import cn.yuan.xiaoyu.commonmodule.manager.HttpManager;
import cn.yuan.xiaoyu.commonmodule.net.ResponseListener;
import cn.yuan.xiaoyu.jokemodule.activity.JokeActivity;
import cn.yuan.xiaoyu.jokemodule.bean.JokeListBean;

/**
 * Created by yukuoyuan on 2017/2/27.
 * 这是一个笑话列表的逻辑层
 */

public class JokePresenter {
    IjokView ijokView;
    JokeActivity jokeActivity;

    public JokePresenter(IjokView ijokView, JokeActivity jokeActivity) {
        this.ijokView = ijokView;
        this.jokeActivity = jokeActivity;
    }

    /**
     * 获取笑话列表数据
     */
    public void getJokeList(int page) {
        HttpManager.getInstance().getJokeList(page, 20, new ResponseListener<JokeListBean>() {
            @Override
            public void onSuccess(JokeListBean jokeListBean) {
                ijokView.setAdapter(jokeListBean);
                ijokView.complete();
                ijokView.closeL();
            }

            @Override
            public void onFailure(String responseresult) {
                ijokView.complete();
                ijokView.closeL();
            }
        });
    }
}
